// Math functions given from https://github.com/terkel/mathsass

// Note: now there is no need to used this.

/**
 * Returns base to the exponent power.
 * @param {Number} $base The base number
 * @param {Number} $exp The exponent to which to raise base
 * @return {Number}
 * @example
 *     pow(4, 2)   // 16
 *     pow(4, -2)  // 0.0625
 *     pow(4, 0.2) // 1.31951
 */
@function pow ($base, $exp) {
    @if $exp == floor($exp) {
        $r: 1;
        $s: 0;
        @if $exp < 0 {
            $exp: $exp * -1;
            $s: 1;
        }
        @while $exp > 0 {
            @if $exp % 2 == 1 {
                $r: $r * $base;
            }
            $exp: floor($exp * 0.5);
            $base: $base * $base;
        }
        @return if($s != 0, 1 / $r, $r);
    } @else {
        @return exp(log($base) * $exp);
    }
}

/**
 * Returns the square root of a number.
 * @param {Number} $x
 * @example
 *    sqrt(2) // 1.41421
 *    sqrt(5) // 2.23607
 */
@function sqrt ($x) {
    @if $x < 0 {
        @warn "Argument for `sqrt()` must be a positive number.";
        @return null;
    }
    $ret: 1;
    @for $i from 1 through 24 {
        $ret: $ret - (pow($ret, 2) - $x) / (2 * $ret);
    }
    @return $ret;
}